package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: AdminShopController
 * Package: com.sky.controller.admin
 * Description:
 *
 * @Author: 比特张
 * @Create: 2023/8/3 - 13:36
 * @Version: v1.0
 */
@Slf4j
@Api(tags = "店铺相关接口")
@RequestMapping("/admin/shop")
@RestController
public class AdminShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    public static final String KEY = "SHOP_STATUS";

    @ApiOperation("设置店铺营业状态")
    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Integer status) {
        redisTemplate.opsForValue().set(KEY, status);
        return Result.success();
    }

    @ApiOperation("获取店铺的营业状态")
    @GetMapping("/status")
    public Result<Integer> getStatus() {
        Integer getStatus = (Integer) redisTemplate.opsForValue().get(KEY);
        return Result.success(getStatus);
    }
}
